package GUI;


import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

import ControlLayer.PartOrderCtr;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class PartOrderMaker extends JFrame {

	private JPanel contentPane;
	private JTextField QField;
	private JTextField PField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					PartOrderMaker frame = new PartOrderMaker();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public PartOrderMaker() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(null);
		setContentPane(contentPane);
		
		JButton btnLavDelorder = new JButton("lav delorder");
		btnLavDelorder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent make) {
				createOrder(make);
			}
		});
		btnLavDelorder.setBounds(335, 228, 97, 25);
		contentPane.add(btnLavDelorder);
		
		JLabel lblKvantitet = new JLabel("kvantitet");
		lblKvantitet.setBounds(12, 13, 56, 16);
		contentPane.add(lblKvantitet);
		
		JLabel productid = new JLabel("productid");
		productid.setBounds(12, 42, 56, 16);
		contentPane.add(productid);
		
		QField = new JTextField();
		QField.setBounds(80, 10, 116, 22);
		contentPane.add(QField);
		QField.setColumns(10);
		
		PField = new JTextField();
		PField.setBounds(80, 39, 116, 22);
		contentPane.add(PField);
		PField.setColumns(10);
	}
	
	private void createOrder(java.awt.event.ActionEvent make) {//GEN-FIRST:event_insertEmp
        PartOrderCtr oCtr = new PartOrderCtr();
        
        int quantity = Integer.parseInt(QField.getText());
        String productid = PField.getText();
       
        
       
            oCtr.insertNew(quantity, productid, "");
        
    }//GEN-LAST:event_insertEmp

}
